home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 February / Practical Internet February 2002.iso / pc / Software / Browsing / httrack-3.09e2.exe / {app} / src / configure next >
Encoding:
Text File  |  2001-10-21  |  13.3 KB  |  508 lines

  1. #!/bin/sh
  2. # No, this isn't generated by autoconf
  3. # Some parts are inspired by autoconf (Free Software Foundation), however
  4. # And the idea is slightly the same
  5.  
  6. # Usage:
  7. # './configure' and then 'make' and 'make install', or
  8. # './configure --make --install'
  9.  
  10. SHELL=/bin/sh
  11.  
  12. ac_prev=
  13. for ac_option
  14. do
  15.   # If the previous option needs an argument, assign it.
  16.   if test -n "$ac_prev"; then
  17.     eval "$ac_prev=\$ac_option"
  18.     ac_prev=
  19.     continue
  20.   fi
  21.  
  22.   case "$ac_option" in
  23.     -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  24.     *) ac_optarg= ;;
  25.   esac
  26.  
  27.   case "$ac_option" in
  28.  
  29.   --pthread | --thread)     THREADS=1   ;;
  30.   --nopthread | --nothread) THREADS=0   ;;
  31.  
  32.   --zlib | --gzip)          ZLIB=1    ;;
  33.   --nozlib | --nogzip)      ZLIB=0    ;;
  34.  
  35.   --static | --noso)        DYNAMIC=0
  36.                             ;;
  37.   --dynamic | --so)         DYNAMIC=1
  38.                             ;;
  39.  
  40.   --longlong)               LONGLONG=1  ;;
  41.   --nolonglong)             LONGLONG=0  ;;
  42.  
  43.   --inaddrt)                NODECLINADDRT=0 ;;
  44.   --noinaddrt)              NODECLINADDRT=1 ;;
  45.  
  46.   --useuid)                 NOUID=0     ;;
  47.   --nouseuid)               NOUID=1     ;;
  48.  
  49.   --useftime)               NOFTIME=0   ;;
  50.   --nouseftime)             NOFTIME=1   ;;
  51.  
  52.   --system=*)               SYSTEMTYPE="$ac_optarg" ;;
  53.   --system)                 ac_prev=SYSTEMTYPE ;;
  54.  
  55.   --debug)                  OTYPE="-O0 -g3"
  56.                             MKTYPE="firstinfo htssystem htssystem_auto build_auto lastinfo" ;;
  57.  
  58.   --make)                   DOMAKE=1    ;;
  59.   --install)                DOINSTALL=1 ;;
  60.   --bininstall)             DOINSTALL=1
  61.                             NODOCINSTALL=1
  62.                             ;;
  63.   --docinstall)             DOINSTALL=1
  64.                             DOCINSTALL=1
  65.                             ;;
  66.   --cls)
  67.     cd ..
  68.     chmod 'u=rw,go=r' `find ./ -type f`
  69.     chmod 'u=rwx,go=rx' `find ./ -type d`
  70.     chmod 'u=rwx,go=rx' ./src/configure
  71.     chmod 'u=rwx,go=rx' ./src/strip_cr.in
  72.     chmod 'u=rwx,go=rx' ./src/postinst-config.in
  73.     cd src
  74.     strip_cr *.c *.h
  75.     rm -f ./httrack 2>/dev/null
  76.     exit    
  77.     ;;
  78.   -prefix | --prefix | --prefi | --pref | --pre | --pr)
  79.     ac_prev=PREFIX ;;
  80.   -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=*)
  81.     PREFIX="$ac_optarg" ;;
  82.   -bindir | --bindir | --bindi | --bind | --bin | --bi)
  83.     ac_prev=BINPATH ;;
  84.   -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
  85.     BINPATH="$ac_optarg" ;;
  86.   -etcdir | --etcdir | --etcdi | --etcd | --etc | --et)
  87.     ac_prev=ETCPATH ;;
  88.   -etcdir=* | --etcdir=* | --etcdi=* | --etcd=* | --etc=* | --et=*)
  89.     ETCPATH="$ac_optarg" ;;
  90.   -libdir | --libdir | --libdi | --libd | --lib | --li)
  91.     ac_prev=LIBPATH ;;
  92.   -libdir=* | --libdir=* | --libdi=* | --libd=* | --lib=* | --li=*)
  93.     LIBPATH="$ac_optarg" ;;
  94.   
  95.   --help)
  96.     cat <<EOF
  97. --prefix=..  : prefix (/usr)
  98. --bindir=..  : binary dir (/usr/bin)
  99. --etcdir=..  : config dir (/usr/etc or /etc)
  100. --libdir=..  : library dir (/usr/lib)
  101. --dynamic    : do use dynamic (.so) mode
  102. --static     : do use static mode
  103. --nopthread  : do not use threads (pthread.h)
  104. --pthread    : do     use threads (pthread.h)
  105. --nozlib     : do not use compression (zlib)
  106. --zlib       : do     use compression (zlib)
  107. --nolonglong : do not use 64-bit int
  108. --longlong   : do     use 64-bit int
  109. --noinaddrt  : do not redeclare in_addr_t
  110. --inaddrt    : do     redeclare in_addr_t
  111. --nouseuid   : do not use setuid()/setgid()
  112. --useuid     : do     use setuid()/setgid()
  113. --nouseftime : do not use ftime()
  114. --useftime   : do     use ftime()
  115. --system=<type> : override system type (uname) (types: 'Default','Linux','SunOS','AIX')
  116. --make       : 'make' after configure
  117. --install    : 'make install' after configure
  118. --bininstall : 'make bininstall' after configure
  119. --docinstall : 'make docinstall' after configure
  120. --debug      : add debug information (for gdb)
  121. EOF
  122.   exit
  123.   ;;
  124.  
  125.   *) echo "Unrecognized option: $ac_option" 
  126.      exit 
  127.      ;;
  128.  
  129.   esac
  130.  
  131. done
  132.  
  133. echo "Welcome to HTTrack Website Copier!"
  134. echo "Type in ./configure --help for more details"
  135. echo "If this script fails, you can enter supplemental options through '--option=value'"
  136. echo "or enter in manual make, through 'make help'"
  137. echo ""
  138.  
  139. if cp -f Makefile.in Makefile; then
  140.  
  141. SEDEXEC=
  142.  
  143. # System (OS) type?
  144. printf "Checking for OS type.. "
  145. if test -z "$SYSTEMTYPE"; then
  146.     SYSTEMTYPE="`uname`"
  147. fi
  148. case "$SYSTEMTYPE" in 
  149.     SunOS) printf "SunOS/Solaris\n"; 
  150.                PLATFORM=0
  151.                SOLSOCK=1
  152.                ;;
  153.     AIX)   printf "AIX\n";           PLATFORM=2 ;;
  154.     *)     printf "Linux type\n";    PLATFORM=3 ;;
  155. esac
  156.  
  157. WTYPE="-Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wnested-externs"
  158.  
  159. if test -z "$OTYPE"; then
  160.     OTYPE="-O3"
  161. fi
  162. if test -z "$MKTYPE"; then
  163.     MKTYPE="firstinfo htssystem htssystem_auto build_auto strip clean lastinfo"
  164. fi
  165.  
  166. # Root group
  167. if test -z "$ROOTGROUP"; then
  168.     printf "Checking for 'root' group.."
  169.     if egrep "^root:" /etc/group >/dev/null; then
  170.         ROOTGROUP="root"
  171.     elif egrep "^wheel:" /etc/group >/dev/null; then
  172.         ROOTGROUP="wheel"
  173.     fi
  174.     printf "$ROOTGROUP\n"
  175. else
  176.     echo "Overriding ROOTGROUP=$ROOTGROUP"
  177. fi
  178.  
  179.  
  180. # Binaries location
  181. if test -z "$BINPATH"; then
  182. printf "Checking for bin directory.. "
  183. if test -n "$PREFIX"; then
  184.     BINPATH="$PREFIX/bin"
  185. elif test -d "/usr/bin"; then
  186.     BINPATH="/usr/bin"
  187. else
  188.     BINPATH="/bin"
  189. fi
  190. printf "$BINPATH\n"
  191. else
  192.     echo "Overriding BINPATH=$BINPATH"
  193. fi
  194.  
  195. # /etc location
  196. if test -z "$ETCPATH"; then
  197. printf "Checking for etc directory.. "
  198. if test -n "$PREFIX"; then
  199.     ETCPATH="$PREFIX/etc"
  200. elif test -d "/usr/etc"; then
  201.     ETCPATH="/usr/etc"
  202. else
  203.     ETCPATH="/etc"
  204. fi
  205. printf "$ETCPATH\n"
  206. else
  207.     echo "Overriding ETCPATH=$ETCPATH"
  208. fi
  209.  
  210. # /usr/lib location
  211. if test -z "$LIBPATH"; then
  212. printf "Checking for lib directory.. "
  213. if test -n "$PREFIX"; then
  214.     LIBPATH="$PREFIX/lib"
  215. elif test -d "/usr/lib"; then
  216.     LIBPATH="/usr/lib"
  217. elif test -d "/usr/local/lib"; then
  218.     LIBPATH="/usr/local/lib"
  219. else
  220.     LIBPATH="/lib"
  221. fi
  222. printf "$LIBPATH\n"
  223. else
  224.     echo "Overriding LIBPATH=$LIBPATH"
  225. fi
  226.  
  227. # Prefix location
  228. if test -z "$PREFIX"; then
  229.     printf "Checking for prefix directory.. "
  230.     PREFIX="/usr"
  231.     printf "$PREFIX\n"
  232. else
  233.     echo "Overriding PREFIX=$PREFIX"
  234. fi
  235.  
  236.  
  237. # 64-bit (long long) cause some troubles to some processors
  238. # because some alignements aren't properly defined
  239. # we only accept 64-bit on tested processors here
  240. if test -z "$LONGLONG"; then
  241. printf "Checking for long long.. "
  242. LONGLONG=
  243. if grep "long long" /usr/include/sys/types.h >/dev/null; then
  244. if uname -a|egrep ' i[3-9]86 ' >/dev/null; then
  245.     LONGLONG=1
  246. fi
  247. fi
  248. if test -n "$LONGLONG"; then
  249.     printf "supported\n"
  250. else
  251.     printf "not tested/supported. Use --LONGLONG=1 to override\n"
  252. fi
  253. else
  254.     echo "Overriding LONGLONG=$LONGLONG"
  255. fi
  256.  
  257. # Dynamic (.so) module?
  258. if test -z "$DYNAMIC"; then
  259.     DYNAMIC=1
  260. fi
  261. printf "Checking for compilation mode: "
  262. if test "$DYNAMIC" -eq "1"; then
  263.     echo "dynamic"
  264.     SOTYPE=-fPIC
  265. else
  266.     echo "static"
  267.     SOTYPE=
  268. fi
  269.  
  270. # Do we not have to redeclare in_addr_t ?
  271. # Sometimes this type is defined, or not..
  272. if test -z "$NODECLINADDRT"; then
  273. printf "Checking for in_addr_t declaration in /usr/include/arpa/inet.h.. "
  274. if grep "in_addr_t" /usr/include/arpa/inet.h >/dev/null; then
  275.     printf "found, do not redeclare\n"
  276.     NODECLINADDRT=1
  277. else
  278.     printf "not found, declaring\n"
  279.     NODECLINADDRT=
  280. fi
  281. else
  282.     echo "Overriding NODECLINADDRT=$NODECLINADDRT"
  283. fi
  284.  
  285. # Test if we can use zlib (/usr/lib/libz.so)
  286. # This allow to speed up transfers using HTTP compression
  287. if test -z "$ZLIB"; then
  288. printf "Checking for /usr/lib/libz.so.. "
  289. if test -f "/usr/lib/libz.so"; then
  290.     printf "found\n"
  291.     ZLIB=1
  292. else
  293.     printf "library not found (too bad), no http compression will be available\n"
  294.     ZLIB=0
  295. fi
  296. else
  297.     echo "Overriding ZLIB=$ZLIB"
  298. fi
  299.  
  300. # Sometimes, pthread.h doesn't exists on some systems
  301. # This is sad, because it speeds up some useful things, like DNS or ftp
  302. if test -z "$THREADS"; then
  303. printf "Checking for /usr/include/pthread.h.. "
  304. if test -f "/usr/include/pthread.h"; then
  305. if test -f "/usr/lib/libpthread.so"; then
  306.     printf "found\n"
  307.     THREADS=1
  308. else
  309.     printf "library not found (too bad), no threads will be available\n"
  310.     THREADS=
  311. fi
  312. else
  313.     printf "not found, no threads will be available\n"
  314.     THREADS=
  315. fi
  316. else
  317.     echo "Overriding THREADS=$THREADS"
  318. fi
  319.  
  320. # Sometimes, setuid and setgid can't be used (missing pwd.h and unistd.h ?!)
  321. if test -z "$NOUID"; then
  322. NOUID=1
  323. printf "Checking for /usr/include/pwd.h and /usr/include/unistd.h.. "
  324. if test -f "/usr/include/pwd.h"; then
  325. if test -f "/usr/include/unistd.h"; then
  326.     NOUID=
  327. fi
  328. fi
  329. if test -z "$NOUID"; then
  330.     printf "found\n"
  331. else
  332.     printf "not found, not using setuid() and setgid()\n"
  333. fi
  334. else
  335.     echo "Overriding NOUID=$NOUID"
  336. fi
  337.  
  338. # Sometimes, ftime can't be used (missing declaration...)
  339. if test -z "$NOFTIME"; then
  340. NOFTIME=1
  341. printf "Checking for ftime in /usr/include/sys/timeb.h.. "
  342. if grep "extern int ftime" /usr/include/sys/timeb.h >/dev/null; then
  343.     NOFTIME=
  344. fi
  345. if test -z "$NOFTIME"; then
  346.     printf "found\n"
  347. else
  348.     printf "not found (too bad), not using ftime()\n"
  349. fi
  350. else
  351.     echo "Overriding NOFTIME=$NOFTIME"
  352. fi
  353.  
  354. # Test variables
  355. if test "$NOUID" = 1; then
  356.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEUID__/HTS_DO_NOT_USE_UID/'"
  357. fi
  358. if test "$NOFTIME" = 1; then
  359.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEFTI__/HTS_DO_NOT_USE_FTIME/'"
  360. fi
  361. if test "$NODECLINADDRT" = 1; then
  362.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEINA__/HTS_DO_NOT_REDEFINE_in_addr_t/'"
  363. fi
  364. if test "$THREADS" = 1; then
  365.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$SOTYPE $OTYPE $WTYPE -D_REENTRANT/g\""
  366.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__/-lpthread/g'"
  367. else
  368.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEPTH__/HTS_DO_NOT_USE_PTHREAD/'"
  369.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$SOTYPE $OTYPE $WTYPE/g\""
  370.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__//g'"
  371. fi
  372. if test "$ZLIB" = 1; then
  373.         SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS3__/-lz/g'"
  374. else
  375.         SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS3__//g'"
  376. fi
  377. SEDEXEC="$SEDEXEC | sed -e \"s/__ZLIB__/$ZLIB/\""
  378. if test "$SOLSOCK" = 1; then
  379.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__/-lnsl -lsocket/g'"
  380. else
  381.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__//g'"
  382. fi
  383. if test ! "$LONGLONG" = 1; then
  384.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINE64B__/HTS_NO_64_BIT/'"
  385. fi
  386. if test "$DYNAMIC" = 1; then
  387.     SEDEXEC="$SEDEXEC | sed -e 's/__DYNAMIC__/so/'"
  388.     SEDEXEC="$SEDEXEC | sed -e 's/__INSTALL__/bininstall libinstall docinstall config/'"
  389.     SEDEXEC="$SEDEXEC | sed -e 's/__UNINSTALL__/binremove libremove docremove/'"
  390. else
  391.     SEDEXEC="$SEDEXEC | sed -e 's/__DYNAMIC__//'"
  392.     SEDEXEC="$SEDEXEC | sed -e 's/__INSTALL__/bininstall docinstall config/'"
  393.     SEDEXEC="$SEDEXEC | sed -e 's/__UNINSTALL__/binremove docremove/'"
  394. fi
  395.  
  396. SEDEXEC="$SEDEXEC | sed -e \"s/__PLATFORM__/$PLATFORM/g\""
  397. SEDEXEC="$SEDEXEC | sed -e 's/#__AUTONAME__/AUTONAME  = auto/'"
  398. SEDEXEC="$SEDEXEC | sed -e 's/#define __DEFINE.*__//g'"
  399.  
  400. # Paths
  401. TMP=`echo $BINPATH | sed -e 's/\\//\\\\\\//g'` 
  402. SEDEXEC="$SEDEXEC | sed -e \"s/__BINPATH__/$TMP/g\""
  403. TMP=`echo $ETCPATH | sed -e 's/\\//\\\\\\//g'`
  404. SEDEXEC="$SEDEXEC | sed -e \"s/__ETCPATH__/$TMP/g\""
  405. TMP=`echo $LIBPATH | sed -e 's/\\//\\\\\\//g'`
  406. SEDEXEC="$SEDEXEC | sed -e \"s/__LIBPATH__/$TMP/g\""
  407. TMP=`echo $PREFIX | sed -e 's/\\//\\\\\\//g'`
  408. SEDEXEC="$SEDEXEC | sed -e \"s/__PREFIX__/$TMP/g\""
  409. TMP=`echo $ROOTGROUP | sed -e 's/\\//\\\\\\//g'`
  410. SEDEXEC="$SEDEXEC | sed -e \"s/__ROOTGROUP__/$TMP/g\""
  411.  
  412. TMP=`echo $PREFIX | sed -e 's/\\//\\\\\\//g'`
  413. SEDEXEC="$SEDEXEC | sed -e \"s/__DEFINEPRE__/$TMP/g\""
  414. SEDEXEC="$SEDEXEC | sed -e 's/__MAKEAUTO__/$MKTYPE/'"
  415.  
  416. # Search for gmake
  417. printf "Checking for make.. "
  418. MAKEPATH=
  419. if test -f "/usr/bin/gmake"; then
  420. MAKEPATH=/usr/bin/gmake
  421. else
  422. if test -f "/bin/gmake"; then
  423. MAKEPATH=/bin/gmake
  424. else
  425. if test -f "/usr/local/bin/gmake"; then
  426. MAKEPATH=/usr/local/bin/gmake
  427. fi
  428. fi
  429. fi
  430. if test -n "$MAKEPATH"; then
  431. printf "found $MAKEPATH\n"
  432. else
  433. MAKEPATH=make
  434. printf "not found, assume make will work\n"
  435. fi
  436.  
  437. # Sed strip_cr
  438. printf "Checking for perl.. "
  439. PERLPATH=
  440. cp -f strip_cr.in strip_cr
  441. if test -f "/usr/bin/perl"; then
  442. PERLPATH=/usr/bin/perl
  443. else
  444. if test -f "/bin/perl"; then
  445. PERLPATH=/bin/perl
  446. else
  447. if test -f "/usr/local/bin/perl"; then
  448. PERLPATH=/usr/local/bin/perl
  449. fi
  450. fi
  451. fi
  452. if test -n "$PERLPATH"; then
  453. printf "found $PERLPATH\nEnsuring that *.c/*.h source files don't contains CR (^M).. "
  454. TMP=`echo $PERLPATH | sed -e 's/\\//\\\\\\//g'` 
  455. cat strip_cr | sed -e "s/__PERL__/$TMP/" >  __tmp; mv __tmp strip_cr
  456. chmod 700 strip_cr
  457. ./strip_cr *.c *.h
  458. printf "done\n"
  459. fi
  460.  
  461. # Sed postinst-config
  462. cp -f postinst-config.in postinst-config
  463. CMD="cat postinst-config $SEDEXEC > __tmp; mv __tmp postinst-config"
  464. if eval $CMD; then
  465. chmod 700 postinst-config
  466. else
  467. echo "Error while seding postinst-config"
  468. exit 1
  469. fi
  470.  
  471. # Sed all __VARS__
  472. CMD="cat Makefile $SEDEXEC > __tmp; mv __tmp Makefile"
  473. echo "Command: $CMD"
  474. if eval $CMD; then
  475.  
  476. echo ""
  477. echo "Makefile created!"
  478. echo "Type in '$MAKEPATH' to build and '$MAKEPATH install' to install"
  479.  
  480. if test -n "$DOMAKE"; then
  481.     echo "Making.."
  482.     eval $MAKEPATH clean
  483.     eval $MAKEPATH
  484. fi
  485. if test -n "$DOINSTALL"; then
  486.     if test -n "$NODOCINSTALL"; then
  487.       echo "Installing binary.."
  488.       eval $MAKEPATH bininstall
  489.     elif test -n "$DOCINSTALL"; then
  490.       echo "Installing docs.."
  491.       eval $MAKEPATH docinstall
  492.     else
  493.       echo "Installing.."
  494.       eval $MAKEPATH install
  495.     fi
  496. fi
  497.  
  498. else
  499.     echo "Error while seding Makefile.."
  500.     exit 1
  501. fi
  502.  
  503. else
  504.     echo "Error copying Makefile.in -> Makefile.. giving up"
  505.         exit 1
  506. fi
  507.  
  508.